package com.tms.operation.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.operation.domain.TmsPickup;
import com.tms.operation.service.ITmsPickupService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 提货单Controller
 *
 * @author ruoyi
 * @date 2024-10-25
 */
@RestController
@RequestMapping("/pickup")
public class TmsPickupController extends BaseController
{
    @Autowired
    private ITmsPickupService tmsPickupService;

    /**
     * 查询提货单列表
     */
    @RequiresPermissions("pickup:pickup:list")
    @GetMapping("/list")
    public TableDataInfo list(TmsPickup tmsPickup)
    {
        startPage();
        List<TmsPickup> list = tmsPickupService.selectTmsPickupList(tmsPickup);
        return getDataTable(list);
    }

    /**
     * 导出提货单列表
     */
    @RequiresPermissions("pickup:pickup:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, TmsPickup tmsPickup)
    {
        List<TmsPickup> list = tmsPickupService.selectTmsPickupList(tmsPickup);
        ExcelUtil<TmsPickup> util = new ExcelUtil<TmsPickup>(TmsPickup.class);
        util.exportExcel(response, list, "提货单数据");
    }

    /**
     * 获取提货单详细信息
     */
    @RequiresPermissions("pickup:pickup:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tmsPickupService.selectTmsPickupById(id));
    }

    /**
     * 新增提货单
     */
    @RequiresPermissions("pickup:pickup:add")
    @PostMapping
    public AjaxResult add(@RequestBody TmsPickup tmsPickup)
    {
        return toAjax(tmsPickupService.insertTmsPickup(tmsPickup));
    }

    /**
     * 修改提货单
     */
    @RequiresPermissions("pickup:pickup:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody TmsPickup tmsPickup)
    {
        return toAjax(tmsPickupService.updateTmsPickup(tmsPickup));
    }

    /**
     * 删除提货单
     */
    @RequiresPermissions("pickup:pickup:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tmsPickupService.deleteTmsPickupByIds(ids));
    }
}
